package com.wx.util;

import io.netty.util.NettyRuntime;
import io.netty.util.internal.SystemPropertyUtil;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;


public class SystemUtil {

    private static final List<String> methodNames=new ArrayList<>();

    public static Integer getCpuNumberOfNuclei(){
        return SystemPropertyUtil.getInt("io.netty.eventLoopThreads", NettyRuntime.availableProcessors());
    }

    public static boolean isObjectMethod(String methodName){
        if(methodNames.isEmpty()){
            Method[] methods = Object.class.getDeclaredMethods();
            for (Method method : methods) {
                String name = method.getName();
                methodNames.add(name);
            }
        }
        boolean contains = methodNames.contains(methodName);
        return contains;
    }
}
